'''
Created on Mar 21, 2012
Description: Verify administrator can login with user name and password default: admin/admin
@author: Vu Dao
'''
import unittest
from Functions.globalFunc import *
from Functions.loginPageFunc import login, openWebsite, isLoginSuccessfully
import time
import HTMLTestRunner

username = readData("username")
password = readData("password")
class Ecom_5002(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5002(self):
        print "Step 1: Open web site"
        openWebsite(self)
        
        print "Step 2: Login web site"
        login(self,username,password)

        print "Step 3: Verify login successfully"
        if isLoginSuccessfully(self):
            print "Passed: Login successfully"
        else:
            print "Failed: Login unsuccessfully"
            
        
    def tearDown(self):
        endCondition(self)
        


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5002)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Verify administrator can login with user name and password default: admin/admin'
                    )
    runner.run(suite)